﻿@model WebVideo.EntityVideo
@{
    ViewBag.Title = @Model.Name.ToString() + " - Yêu quảng cáo";
}

@{
    //Session["AdminId"] = "Admin"; 
    if (System.Web.HttpContext.Current.Request.Cookies["userId"] == null)
    {
        Response.Redirect(@Url.Action("Index", "Index"));

    }
     
}
<script>
    document.body.className = 'no-js video'
    var player,
        firstQ = false,
        width = 640,
        height = 360;
    width = $('.videoPlayer').width();
    height = width * 0.5625;
   
    function onYouTubeIframeAPIReady() {
        player = new YT.Player('player', {
            videoId: '@Model.Video',
            //playerVars: { 'controls': 0, 'showinfo': 0 }
        });
        $('iframe').each(function () {
            var url = $(this).attr("src");
            var char = "?";
            if (url.indexOf("?") != -1) {
                var char = "&";
            }
            $(this).attr("src", url + char + "wmode=transparent");
        });
    }
    function playVideo() {
        player.playVideo();
        $('.playVideo').fadeOut(200, function () {
            $('#widget-hd').show();
            var getURL = '@Url.Action("KiemTraVideo", "Index")';
            var IdVideo = @Model.Id
            $.get(getURL, { "IdVideo": IdVideo }, function (data) {
                if (data == "error") {
                    $('#widget-hd').fadeOut(1000);
                    $('#img1').hide();
                }
            });
            var path = "../../Content/Images/Video/" + $('#ImageQuetion').val() + "?wmode=transparent";
            $('#img1').attr("src", path);
            var dep = $('#ImageDeplay').val();
            var deplay1 = parseInt(dep) * 1000;
            $('.imgQuestion').delay(deplay1).fadeIn(300, function () {
                aniLeft();
                setTimeout(demthoigian, 5000);
            });
        });
    }
    function demthoigian() {
        $('#img1').hide();
    }
    function aniLeft() {
        $('.imgQuestion').animate({ left: 220 }, 800, function () { aniRight() })
    }
    function aniRight() {
        $('.imgQuestion').animate({ left: 10 }, 700, function () { aniLeft() })
    }
    function ChamDiemTracNgiem() {
        var kt = 0;
            var kq = $("input[name=CH]:checked").val();  // người dùng chọn
            if (kq == undefined) {
                kt = -1;
                $('#MatKhauError').text('Bạn vui lòng check câu trả lời');
                $('#frmERROR').modal('show');
               
            }
        if (kt == 0) {
            var getURL = '@Url.Action("CauHoiTracNgiem", "Index")';
            var STT = $("#STT").val();
            $("#btnHoanThanh").hide();
            $("#imgLoader").show();
            var IdVideo = '@Model.Id';
            if (STT == "-2") {
                $('#MatKhauError').text('Bạn đã hoàn thành xong bảng câu hỏi khảo sát');
                $('#frmERROR').modal('show');
                $('#widget-hd').fadeOut(1000);
                $.get(getURL, { "IdVideo": IdVideo, "STT": -2, "ArrR": kq }, function (data) {
                  
                });
            }
           
            
            $.get(getURL, { "IdVideo": IdVideo, "STT": STT, "ArrR": kq }, function (data) {
                $('div.qs-content-inner').html(data);
                $("#btnHoanThanh").show();
                $("#imgLoader").hide();
            });
        }
        var getURL = '@Url.Action("checkview", "Index", new { IdV = @Model.Id })';
         $.get(getURL);
     }

     function ChamDiemTuLuan() {
       
         var kt = 0;
         var kq = $("#CH").val();  // người dùng chọn
         if (kq == "") {
             kt = -1;
             $('#MatKhauError').text('Bạn vui lòng trả lời câu hỏi');
             $('#frmERROR').modal('show');
             return;
         }
         if (kt == 0) {
             $("#btnHoanThanh").hide();
             $("#imgLoader").show();
             var getURL = '@Url.Action("_CauHoiTuLuan", "Index")';
             var STT = $("#STT").val();
             var IdVideo = '@Model.Id';
            if (STT == "-2") {
                $('#MatKhauError').text('Bạn đã hoàn thành xong bảng câu hỏi khảo sát');
                $('#frmERROR').modal('show');
                $('#widget-hd').fadeOut(1000);
                $.get(getURL, { "IdVideo": IdVideo, "STT": -2, "ArrR": kq }, function (data) {
                });
                return;
               
            }
            $.get(getURL, { "IdVideo": IdVideo, "STT": STT, "ArrR": kq }, function (data) {
                $('div.qs-content-inner').html(data);
                $("#btnHoanThanh").show();
                $("#imgLoader").hide();
            });
        }
        var getURL = '@Url.Action("checkview", "Index", new { IdV = @Model.Id })';
         $.get(getURL);
    }
    function checkFirst() {

        var kq = $("input[name=Ques]:checked").val();// người dùng chọn
        var da = $("#ResultQuetion").val(); // đáp án
        if (kq == da) {
            $('.imgQuestion').fadeOut(100, function () {
                $(this).animate().stop();
            });
            $('.firstQuestion').fadeOut(100);
            var getURL = '@Url.Action("Check_First_Watch_Video", "Index")';
            $.get(getURL, { "IdVideo": '@Model.Id' }, function (data) {
                if (data == "Complete") {// không phải lần đầu tiên xem
                    $('#widget-hd').hide();
                    $('#MatKhauError').text('Chúc mừng bạn đã hoàn thành câu hỏi');
                    $('#frmERROR').modal('show');
                }
            });
        } else {
            $('#MatKhauError').text('Bạn đã trả lời sai, video sẽ được load lại');
            $('#frmERROR').modal('show');
            setTimeout(Replay, 1500);
          
            }

    }
    function Replay() {
        window.location.href = '@Url.Action("NView", "Index", new { IdVideo = @Model.Id })';
    }
    function LikeComment(Id) {
        var getURL = '@Url.Action("_CommentVideo", "Index")';
                           var IdVideo = @Model.Id
                           $.get(getURL, { "IdVideo": IdVideo, "Comment": "", "IdComment": Id, "IdEdit": 0, "IdDelete": 0 }, function (data) {
                               $("div.comment-full").html(data);
                           });
    }

    function DeleteComment(Id) {
        var getURL = '@Url.Action("_CommentVideo", "Index")';
                           var IdVideo = @Model.Id
                           $.get(getURL, { "IdVideo": IdVideo, "Comment": "", "IdComment": 0, "IdEdit": 0, "IdDelete": Id }, function (data) {
                               $("div.comment-full").html(data);
                           });
    }

    function Comment(e) {
        var key;
        if (window.event)
            key = window.event.keyCode;     //IE 
        else
            key = e.which;
        if (key == 13) {

            var getURL = '@Url.Action("_CommentVideo", "Index")';
             var Comment = $('#CommentVideo').val();
             var IdVideo =  @Model.Id
                 $.get(getURL, { "IdVideo": IdVideo, "Comment": Comment, "IdComment": 0, "IdEdit": 0, "IdDelete": 0 }, function (data) {
                     $("div.comment-full").html(data);
                 });
         }
         return true;
     }

    $(document).ready(function () {
        $('#widget-hd').hide();

        $("#btnHoanThanh").show();
        $("#imgLoader").hide();
         });
</script>
<div class="normal arrow left">‹</div>
        <div class="normal arrow right">›</div>
<div class="inner-container" id="inner-container" style="width: 8000px;">
    <div class="wrap-widget" id="abc">
        <div class="inner-widget _11">
            <h1>Xem quảng cáo</h1>
            <div class="widget _4x3 phone">
                <div class="videoPlayer">
                    <div id="player" wmode="Opaque"></div>
                    <div class="imgQuestion">
                        <img src="../../Content/cssFrontEnd/upload/avatar/avatar.jpg" id="img1" />
                    </div>
                    <div class="playVideo" onclick="playVideo()"></div>
                </div>
                <!--/ videoPlayer-->
                <div class="description">
                    <h2>@Model.Name</h2>
                    <p class="vote _4">View: <span>@Model.Viewed</span></p>
                    <p class="company">
                        @{string v = "~/Content/Images/Avatar/" + Model.EntityBusiness.Avatar.ToString();
                       
                            <p class="company">
                                <img src="@Url.Content(v)" /><span>@Model.EntityBusiness.CompanyName</span>
                            </p>  
                        }
                </div>
                <!--/ description-->
            </div>
            <!--/ .widget-->

            <div class="widget _3x3 phone bg-color-grayLight" id="widget-hd">
                <!-- -->
                <div class="widget-hd">Câu hỏi dành cho bạn</div>
                <!--s -->
                <div class="widget-content">
                        <div class="qs-content-inner">
                            @{
                                if (Model.TypeQuestion == 2)
                                {
                                @Html.Action("CauHoiTracNgiem", "Index", new { IdVideo = @Model.Id , STT = -1, ArrR = ""});

                                }
                                else
                                {
                                @Html.Action("_CauHoiTuLuan", "Index", new { IdVideo = @Model.Id , STT = -1, ArrR = "" });
                                }
                         
                            }

                        </div>
                        <!--/ .qs-content-inner-->
                    <!--/ .qs-content-->
                    <div class="qs-button">
                        <img src="/Content/Images/loader9.gif" id ="imgLoader" class ="pull-right" />
                        @{
                          if(Model.TypeQuestion == 1)
                          { 
                            <button class="btn-normal pull-right" id ="btnHoanThanh" onclick="return ChamDiemTuLuan();">Trả lời</button>
                        }
                        else
                        {
                              <button class="btn-normal pull-right" id ="btnHoanThanh" onclick=" return ChamDiemTracNgiem();">Trả lời</button>
                        }
                            
                        }

                    </div>

                </div>
                <div class="firstQuestion">
                    <div class="widget-hd">Câu hỏi đầu  | <small>Bạn nhìn hình xuất hiện trên video để trả lời câu hỏi sau</small></div>
                    <div class="widget-content">
                        <p class="text-error">Bạn trả lời sai, trả lời câu hỏi khác</p>
                        <div class="qs-item" id="widget-content1">
                            @Html.Action("_ImageVideo", "Index", new { IdVideo = @Model.Id })
                        </div>
                        <!---/ .qs-item-->
                    </div>
                    <div class="qs-button">
                        <button class="btn-normal pull-right" onclick="checkFirst()">Trả lời</button>
                    </div>
                </div>
                <!--/ .firstQuestion-->
            </div>
            <!--/ .widget-->

            <div class="widget _2x3 phone bg-color-white">
                <div class="box-social-wrapper contScroll">
                    <div class="widget-hd">Bình luận</div>
                    <div class="box-social">
                        <div class="comment-full" style="margin-left: 0; border-top: none;">

                            @Html.Action("_CommentVideo", "Index", new { IdVideo = @Model.Id, Comment = "", IdComment = 0, IdEdit = 0, IdDelete = 0 })

                        </div>
                        <!--/ .comment-full-->
                    </div>
                    <!--/ .box-social-->
                </div>
                <!--/ .box-social-wrapper-->
            </div>
            <!--/ .widget-->

            <div class="widget _2x2 phone bg-color-grayLight">
                <div class="widget-hd">
                    <span>

                        <img src="@Url.Content(v)"  height="30" width="30"/></span>@Model.EntityBusiness.CompanyName
                </div>
                <div class="widget-content">
                    <p>
                        Trụ sở công ty @Model.EntityBusiness.CompanyName<br />
                        Visiting address:
                    </p>
                    <p>

                        @Model.EntityBusiness.Address<br />
                        Tel:  @Model.EntityBusiness.PhoneNumber<br />
                        Website: <a href="@Model.EntityBusiness.website" target="_blank">@Model.EntityBusiness.website</a>
                    </p>
                    <div class="fb-like-box" data-href="@Model.EntityBusiness.LinkFanpage" data-width="304" data-height="110" data-show-faces="false" data-header="false" data-stream="false" data-show-border="true"></div>
                </div>
            </div>
            <!--/ .widget-->
            <div class="widget _2x1 phone bg-color-grayLight">
                <div class="widget-hd">Thống kê</div>
                <div class="widget-content">
                    <ul>
                        <li>Đăng ngày: @Model.Date.Value.ToString("dd-MM-yyyy")</li>
                        <li>Độ dài video: @Model.EntityTypeVideo.Name</li>
                        <li>Số lượt đã xem: @Model.Viewed</li>
                    </ul>
                </div>
            </div>

            <!--/ .widget-->
        </div>
        <!--/ .inner-widget-->
    </div>
    <!--/ .wrap-widget -->
</div>


@section occasionalScripts {
    <script type="text/javascript" src="@Url.Content("~/Content/cssFrontEnd/js/jquery.min.js")" ></script>
    <script type="text/javascript" src="@Url.Content("~/Content/cssFrontEnd/js/load.js")" ></script>
    <script type="text/javascript" src="@Url.Content("~/Content/cssFrontEnd/js/styles.js")" ></script>
    <script type="text/javascript" src="@Url.Content("~/Content/cssFrontEnd/js/jquery.nicescroll.min.js")" ></script>
    <script type="text/javascript" src="https://www.youtube.com/iframe_api"></script>

}
<div id="fb-root"></div>
<script>(function (d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/vi_VN/all.js#xfbml=1&appId=488261941263517";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<style>
    .widget-hd img {
        width: 40px !important;
        height: 38px !important;
        margin: -10px 8px -6px -10px !important;
    }
</style>

